package com.ecnu.common.enums;

import java.util.HashMap;
import java.util.Map;

public enum CommonType {

    BOTTOM_MESSAGE(1, "底栏消息设置"),
    ACTIVITY_NAME(2, "活动名称设置"),
    BANNER(3, "轮播图设置"),
    HOME_MESSAGE(4, "首页消息设置");

    private final int code;
    private final String name;

    CommonType(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String getNameByCode(int code) {
        for (CommonType type : CommonType.values()) {
            if (type.getCode() == code) {
                return type.getName();
            }
        }
        return null;
    }

    public static Map<String, Integer> getCodeNameMap() {
        Map<String, Integer> codeNameMap = new HashMap<>();
        for (CommonType type : CommonType.values()) {
            codeNameMap.put(type.getName(), type.getCode());
        }
        return codeNameMap;
    }
}
